<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
echo "<h2>Страницы сайта</h2>";
$this->table->set_heading('id', 'Название', 'Сортировка', '', 'Действия');
$tmpl = array('table_open' => '<table border="0" cellpadding="0" cellspacing="0" class="admin_table content_table">');
$this->table->set_template($tmpl);

$class = 'content';
if ($this->users_rights_model->check_rights($class, 'block', true)) $canblock = 1;
if ($this->users_rights_model->check_rights($class, 'unblock', true)) $canblock = 1;
if ($this->users_rights_model->check_rights($class, 'edit', true)) $canedit = 1;
if ($this->users_rights_model->check_rights($class, 'delete', true)) $candelete = 1;
if ($this->users_rights_model->check_rights($class, 'add', true)) $canadd = 1;
$d = 0;
foreach ($pages as $page) {
	$seg = sizeof(explode("&", $page['page_path'])) - 2;
	$i = 0;
	$add_text = "";
	while ($i < $seg) {
		$add_text .= "<div style='float: left; width: 20px;'>&nbsp;</div>";
		$i++;
	}
	$d++;


	$page_title = $add_text;
	$page_title .= "<a href='#' class='block_".$page['page_parent']."' onclick='openclose(".$page['page_id'].");' rel='".$page['page_id']."'>";
	if (mb_strlen($page['page_title']) > 30) {
		$text = mb_substr($page['page_title'], 0, 30)."...";
	} else {
		$text = $page['page_title'];
	}
	if (mb_strlen($page['page_curl']) > 15) {
		$text .= "</a> <small>[".mb_substr($page['page_curl'], 0, 15)."...]</small>";
	} else {
		$text .= "</a> <small>[".$page['page_curl']."]</small>";
	}
		$page_title .= $text;

	$hide = "";
	if ($page['page_parent'] != 0) {
		$hide = "must_hide";
		if (get_cookie('tr_'.$page['page_id'])=='show') $hide = "";
	}

	$this->table->add_row(
			$page['page_id'],
			array('data' => $page_title, 'class' => 'page_title '.$hide),
			array('data' => $add_text."<input class='ordering' type='text' tabindex='".$d."' value='".$page['page_order']."' name='order[".$page['page_id']."]' />", 'style' => 'text-align: left; width: 120px;'),
			array('data' => ($page['page_model'] != ""?"<img src='/data/images/icons/modul.png' style='border: 0px !important; margin: 0px; padding: 0px;' alt='Модуль' title='Модуль' />":""), 'style' => 'text-align: center;width: 30px;'),
			showmeactions(
					$class,
					$page['page_id'],
					$page['page_status'],
					$canedit, $candelete, $canblock,
					$from
				)
		);
}
$d++;
	$this->table->add_row(
			"",
			"",
			array('data' => "<input type='submit' tabindex='".$d."' class='ordering' value='Сохранить' />", 'style' => 'text-align: center; width: 80px;'),
			"",
			""
		);

echo "<form action='/admin/content/ordering/' method='post'>";
echo $this->table->generate();
echo "</form>";
echo $paging;
if ($canadd == 1) {
	echo showmeadd($class, 'Добавить страницу');
}
echo "<div class='cc'></div>";
?>
